<template>
  <!--弹出窗-->
  <modal ref="modal_1"
         :title="title"
         :isCloseConfirm="this.editable"
         :fullscreen="this.fullscreen"
         top="5%"
         width="50%"
         :close-on-click-modal="true"
         @modalOpened="opened"
         @modalClose="closed">

    <avue-form :option="option"
               ref="form"
               v-model="form"
               @submit="onSubmit"
               :upload-before="uploadBefore"
               :upload-after="uploadAfter"
               :upload-exceed="uploadExceed"
               :upload-error="uploadError"  @error="handleValidateError">
      <template #chartId v-if="this.editable">
        <el-input v-model="form.chartId" readonly placeholder="请选择编号前缀" @click="selectChartId" :disabled="!!this.form.id"/>
      </template>
      <!--<template #programCode>-->
        <!--<el-select v-model="form.programCode" placeholder="请选择品牌代号" filterable clearable>-->
          <!--<el-option-->
                  <!--v-for="item in customerGroupList"-->
                  <!--:key="item.programCode"-->
                  <!--:label="item.programName"-->
                  <!--:value="item.programCode"-->
          <!--&gt;-->
          <!--</el-option>-->
        <!--</el-select>-->
      <!--</template>-->
    </avue-form>

    <!--底部按钮块, 默认只有"取消"按钮-->
    <template #footerButton>
      <el-button
              type="primary"
              v-if="(permission.material_add || permission.material_edit) && editable"
              :loading="btnLoading"
              @click="this.$refs.form.submit()"
      >保 存
      </el-button>
      <el-button @click="$refs.modal_1.handleClose()">关闭</el-button>
    </template>
    <select-front ref="selectFront" @success="setMaterialFront"></select-front>
  </modal>
</template>

<script>
    import {getList, getDetail, add, update, remove, getMaterialFront} from "@/api/anwise/material/material";
    import {selectCustomerGroup, generatePackLabel} from "@/api/anwise/material/customer_group";
    import {Pattern} from "@/utils/validate.js";
  import {mapGetters} from "vuex";
  import selectFront from "@/views/anwise/material/components/select_material_front.vue";

  export default {
      components: {
          selectFront,
      },
    data() {
      return {
        emits: ["success"],
          customerGroupList:[],
          fixed:false,
        editable: false,
        title: "物料基本资料",
        isCloseConfirm: false,
        fullscreen: false,
        form: {},
        query: {},
        loading: true,
          btnLoading: false,
        option: {
          height: 'auto',
          calcHeight: 30,
          labelWidth: 150,
          menuWidth: 120,
          submitBtn: false,
          emptyBtn: false,
          column: [
              {
                  label: "编号前缀",
                  prop: "chartId",
                  type: "input",
                  rules: [{
                      required: true,
                      message: "请输入编号前缀",
                      trigger: "blur"
                  }],
              },
              {
                  label: "物料编号",
                  prop: "materialNo",
                  type: "input",
                  readonly:true,
                  disabled:true,
                  placeholder:"请输入物料编号",
                  rules: [{
                      required: false,
                      message: "请输入物料编号",
                      trigger: "blur"
                  }],
              },
              {
                  label: "",
                  prop: "place",
                  type: "",
                  detail:true,
                  span: 8,
                  display:false,
                  // labelPosition: "top",
              },
              {
                  label: "客户条码",
                  prop: "barCode",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入客户条码",
                      trigger: "blur"
                  }],
              },
              {
                  label: "物料名称",
                  prop: "materialName",
                  type: "input",
                  rules: [{
                      required: true,
                      message: "请输入物料名称",
                      trigger: "blur"
                  }],
              },
              {
                  label: "配件名称",
                  prop: "partName",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入配件名称",
                      trigger: "blur"
                  }],
              },
              {
                  label: "规格",
                  prop: "specification",
                  type: "input",
                  maxlength:400,
                  rules: [{
                      required: false,
                      message: "请输入规格",
                      trigger: "blur"
                  }],
              },
              {
                  label: "颜色",
                  prop: "color",
                  type: "select",
                  filterable:true,
                  dicUrl: "/blade-system/dict-biz/dictionary?code=color",
                  width:120,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择颜色",
                      trigger: "blur"
                  }],
              },
              {
                  label: "类别",
                  prop: "type",
                  type: "select",
                  filterable:true,
                  dicUrl: "/blade-system/dict-biz/dictionary?code=material_s_type",
                  width:120,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
                  change:	({column,value})=>{this.changeType(value);},
                  rules: [{
                      required: true,
                      message: "请选择类别",
                      trigger: "blur"
                  }],
              },
              {
                  label: "烫金纸规格",
                  prop: "mxh",
                  type: "select",
                  filterable:true,
                  dicUrl: "/blade-system/dict-biz/dictionary?code=tjz_type",
                  width:120,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择烫金纸规格",
                      trigger: "blur"
                  }],
              },
              {
                  label: "产品logo",
                  prop: "mtz",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入产品logo",
                      trigger: "blur"
                  }],
              },
              {
                  label: "材质",
                  prop: "mcz",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入材质",
                      trigger: "blur"
                  }],
              },
              {
                  label: "是否整箱开单",
                  prop: "abc",
                  type: "select",
                  dicUrl: "/blade-system/dict-biz/dictionary?code=biz_yes_no",
                  filterable: true,
                  overHidden: true,
                  search: true,
                  sortable: true,
                  width:150,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择是否整箱开单",
                      trigger: "blur"
                  }],
                  change:	({column,value})=>{this.changeAbc(value)},
              },
              {
                  label: "长度",
                  prop: "length",
                  type: "number",
                  value:0,
                  precision:2,
                  min:0,
                  max:999999999,
                  controls:false,
                  rules: [{
                      required: true,
                      message: "请输入长度",
                      trigger: "blur"
                  }],
              },
              {
                  label: "长度单位",
                  prop: "lengthUnit",
                  type: "select",
                  filterable:true,
                  disabled:true,
                  dicUrl: '/api/blade-anwise/unit_info/select?type=length',
                  props: {
                      label: 'name',
                      value: 'name',
                  },
                  dataType: 'string',
                  value:'CM',
                  rules: [{
                      required: true,
                      message: "请选择长度单位",
                      trigger: "blur"
                  }],
              },
              {
                  label: "宽度",
                  prop: "width",
                  type: "number",
                  value:0,
                  precision:2,
                  min:0,
                  max:999999999,
                  controls:false,
                  rules: [{
                      required: true,
                      message: "请输入宽度",
                      trigger: "blur"
                  }],
              },
              {
                  label: "宽度单位",
                  prop: "widthUnit",
                  type: "select",
                  filterable:true,
                  disabled:true,
                  dicUrl: '/api/blade-anwise/unit_info/select?type=length',
                  props: {
                      label: 'name',
                      value: 'name',
                  },
                  dataType: 'string',
                  value:'CM',
                  rules: [{
                      required: true,
                      message: "请选择宽度单位",
                      trigger: "blur"
                  }],
              },
              {
                  label: "高度",
                  prop: "height",
                  type: "number",
                  value:0,
                  precision:2,
                  min:0,
                  max:999999999,
                  controls:false,
                  rules: [{
                      required: true,
                      message: "请输入高度",
                      trigger: "blur"
                  }],
              },
              {
                  label: "高度单位",
                  prop: "heightUnit",
                  type: "select",
                  filterable:true,
                  disabled:true,
                  dicUrl: '/api/blade-anwise/unit_info/select?type=length',
                  props: {
                      label: 'name',
                      value: 'name',
                  },
                  value:'CM',
                  dataType: 'string',
                  rules: [{
                      required: true,
                      message: "请选择高度单位",
                      trigger: "blur"
                  }],
              },
              {
                  label: "每个/包重",
                  prop: "weight",
                  type: "input",
                  value:0,
                  rules: [{
                      required: false,
                      message: "请输入每个/包重",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }],
              },
              {
                  label: "重量单位",
                  prop: "weightUnit",
                  type: "select",
                  filterable:true,
                  dicUrl: '/api/blade-anwise/unit_info/select?type=weight',
                  props: {
                      label: 'name',
                      value: 'name',
                  },
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择重量单位",
                      trigger: "blur"
                  }],
              },
              {
                  label: "海关编码",
                  prop: "mateGroup",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入海关编码",
                      trigger: "blur"
                  }],
              },
              {
                  label: "每箱净重(KG)",
                  prop: "salesNum",
                  type: "input",
                  value:0,
                  rules: [{
                      required: false,
                      message: "请输入每箱净重(KG)",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }],
              },
              {
                  label: "每箱毛重(KG)",
                  prop: "cost",
                  type: "input",
                  value:0,
                  rules: [{
                      required: false,
                      message: "请输入每箱毛重(KG)",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }],
              },
              {
                  label: "安全仓存",
                  prop: "costUnit",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入安全仓存",
                      trigger: "blur"
                  }],
              },



              {
                  label: "系列代码",
                  prop: "seriesNo",
                  type: "select",
                  filterable:true,
                  dicUrl: '/api/blade-anwise/material_series/select',
                  props: {
                      label: 'seriesNo',
                      value: 'id',
                  },
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择系列代码",
                      trigger: "blur"
                  }],
              },
              // {
              //     label: "品牌代号",
              //     prop: "programCode",
              //     type:"select",
              //     filterable:true,
              //     dicUrl: '/api/blade-anwise/customer_group/select',
              //     props: {
              //         label: 'programCode',
              //         value: 'programCode',
              //     },
              //     dataType: 'string',
              //     // change:	({column,value})=>{this.generatePackLabel(value);},
              //     rules: [{
              //         required: false,
              //         message: "请选择品牌代号",
              //         trigger: "blur"
              //     }],
              // },
              {
                  label: "每外箱数量",
                  prop: "maxNum",
                  type: "number",
                  value:'0',
                  precision:0,
                  min:0,
                  max:999999999,
                  controls:false,
                  rules: [{
                      required: false,
                      message: "请输入每外箱数量",
                      trigger: "blur"
                  }]

              },
              {
                  label: "每内箱数量",
                  prop: "minNum",
                  type: "number",
                  precision:0,
                  min:0,
                  max:999999999,
                  controls:false,
                  value:'0',
                  rules: [{
                      required: false,
                      message: "请输入每内箱数量",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }]

              },
              {
                  label: "每袋数量",
                  prop: "saveNum",
                  type: "number",
                  precision:0,
                  min:0,
                  max:999999999,
                  controls:false,
                  value:'0',
                  rules: [{
                      required: false,
                      message: "请输入每袋数量",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }]

              },
              {
                  label: "包装体积",
                  prop: "packSize",
                  type: "input",
                  value:'0',
                  rules: [{
                      required: false,
                      message: "请输入包装体积",
                      trigger: "blur"
                  },{
                      pattern: Pattern.amount_w,
                      message: '请输入正确的数字',
                      trigger: 'blur',
                  }]
              },
              {
                  label: "是否有效",
                  prop: "isActive",
                  type: "select",
                  dicUrl: "/blade-system/dict-biz/dictionary?code=biz_yes_no",
                  filterable: true,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  value:'是',
                  dataType: 'string',
                  rules: [{
                      required: false,
                      message: "请选择是否有效",
                      trigger: "blur"
                  }],
              },
              {
                  label: "箱唛颜色",
                  prop: "labelColor",
                  type: "select",
                  dicUrl: "/blade-system/dict-biz/dictionary?code=label_color",
                  filterable: true,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
              },
              {
                  label: "图纸编号",
                  prop: "photoNo",
                  type: "input",
                  rules: [{
                      required: false,
                      message: "请输入图纸编号",
                      trigger: "blur"
                  }],
              },
              {
                  label: "纸箱编号",
                  prop: "cartonNo",
                  type: "input",
                  disabled:true,
                  readonly:true,
                  rules: [{
                      required: false,
                      message: "请输入纸箱编号",
                      trigger: "blur"
                  }],
              },
              {
                  label: "箱唛说明",
                  prop: "salesUnit",
                  type: "textarea",
                  span:24,
                  minRows:2,
              },
              {
                  label: "备注",
                  prop: "remark",
                  type: "textarea",
                  span: 24,
                  minRows:2,
              },
              {
                  label: "包装规格",
                  prop: "packRemark",
                  type: "textarea",
                  span: 24,
                  minRows:2,
              },
              {
                  label: "标准箱唛",
                  prop: "packLabel",
                  type: "textarea",
                  span: 24,
                  minRows:2,
                  // value:'条纹码位置：xxxxx(code128) \r' +
                  //     '${barCode}\r' +
                  //     '${numUnit}\r' +
                  //     '${color}\r' +
                  //     '${salesUnit}\r' +
                  //     '${mateGroup}',
              },
              {
                  label: "特殊箱唛",
                  prop: "packLabel2",
                  type: "textarea",
                  span: 24,
                  minRows:2,
              },
              {
                  label: "工序备注",
                  prop: "workListRemark",
                  type: "textarea",
                  span: 24,
                  minRows:2,
                  disabled:true,
              },
              {
                  label: "物料图片",
                  prop: "fileList",
                  type: "upload",
                  listType: 'picture-card',
                  action: '/blade-resource/file/upload',
                  accept:'.png,.jpg,.jpeg,.bpm,.gif',
                  // fileType: 'img',
                  tip: '只能上传png/jpg/jpeg/bpm/gif，且不超过10M，数量不超过10张',
                  limit: 10,
                  fileSize: 10000,
                  span: 24,
                  propsHttp: {
                      res: 'data',
                      url: 'url',
                  },
                  // canvasOption: {
                  //     text: 'ANWISE ERP CLOUD',
                  //     ratio: 0.1,
                  // },
              },
              {
                  label: "bom审批状态",
                  prop: "isAssign",
                  type: "select",
                  dicUrl: "/blade-system/dict-biz/dictionary?code=biz_yes_no",
                  filterable: true,
                  disabled:true,
                  props: {
                      label: 'dictValue',
                      value: 'dictValue',
                  },
                  dataType: 'string',
              },
              {
                  label: "bom审批人",
                  prop: "assignName",
                  type: "input",
                  display: false,
                  disabled:true,
              },
              {
                  label: "bom审批时间",
                  prop: "assignTime",
                  type: "input",
                  display: false,
                  disabled:true,
              },
              {
                  label: "创建人",
                  prop: "createUserName",
                  type: "input",
                  display: false,
                  disabled:true,
              },
              {
                  label: "创建时间",
                  prop: "createTime",
                  type: "input",
                  display: false,
                  disabled:true,
              },
          ]
          },
          data: []
        };
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          addBtn: this.validData(this.permission.material_add, false),
          viewBtn: this.validData(this.permission.material_view, false),
          delBtn: this.validData(this.permission.material_delete, false),
          editBtn: this.validData(this.permission.material_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
      mounted() {
          // this.initDict();
      },
    methods: {
        changeAbc(value) {
            if (value == '是') {
                this.findObject(this.option.column, 'maxNum').rules[0].required = true;
                // this.findObject(this.option.column, 'maxNum').rules[1] = {
                //     pattern: Pattern.number_1,
                //     message: '每外箱数量必须大于0！',
                //     trigger: 'blur',
                // };
            } else {
                this.findObject(this.option.column, 'maxNum').rules[0].required = false;
                // this.findObject(this.option.column, 'maxNum').rules[1] = {};
            }
        },
        changeType(value) {
          if (value) {
              if (value == '成品') {
                  this.findObject(this.option.column, 'mtz').rules[0].required = true;
                  this.findObject(this.option.column, 'mateGroup').rules[0].required = true;
              } else {
                  this.findObject(this.option.column, 'mtz').rules[0].required = false;
                  this.findObject(this.option.column, 'mateGroup').rules[0].required = false;
              }
          }
        },
        // generatePackLabel(value) {
        //     if (value) {
        //         this.form.programCode = value;
        //         console.log("进来了~");
        //         console.log(this.form);
        //         generatePackLabel(this.form).then(res => {
        //             if (res.data.success) {
        //                 this.form.packLabel = res.data.data.packLabel;
        //                 this.form.packLabel2 = res.data.data.packLabel2;
        //                 this.form.packLabel3 = res.data.data.packLabel3;
        //             }
        //         }).catch(err => {
        //             console.log(err)
        //             this.$message({
        //                 type: "error",
        //                 message: "获取品牌分组数据异常！"
        //             });
        //         })
        //     }
        // },
          initDict() {
              selectCustomerGroup().then(res => {
                  if (res.data.success) {
                      this.customerGroupList = res.data.data;
                  }
              }).catch(err => {
                  console.log(err)
                  this.$message({
                      type: "error",
                      message: "获取品牌分组数据异常！"
                  });
              })
          },
        setMaterialFront(data) {
          console.log(data);
          this.form.chartId = data.parentCode;
          if (data.parentCode.startsWith('P')) {
              this.form.type='成品';
          } else if (data.parentCode.startsWith('S')) {
              this.form.type='半成品';
          } else if (data.parentCode.startsWith('R')) {
              this.form.type='原料';
          }
            // getMaterialFront(data.id).then(res => {
            //     if (res.data.success) {
            //         let data = res.data.data;
            //         this.form.chartId = data.chartId;
            //         // this.form.materialNo = data.materialNo;
            //     }
            // }).catch(err => {
            //     console.log(err)
            //     this.$message({
            //         type: "error",
            //         message: "生成前缀发生异常！"
            //     });
            // })
        },
        selectChartId() {
          this.$refs.selectFront.showSelect();
        },
        onSubmit(form, done) {
            this.btnLoading = true;
            if (form.imgList) {
                form.imgList.forEach((item, index) => {
                    if (!form.fileList.includes(item.url)) {
                        form.imgList.splice(index, 1);
                    }
                })
            }
            console.log(form);
            update(form).then(res => {
                done();
                this.btnLoading = false;
                if (res.data.success) {
                    this.$message({
                        type: "success",
                        message: res.msg || "保存成功!"
                    });
                    setTimeout(() =>{
                        this.$refs.modal_1.hide();
                    },1000)
                } else {
                    this.$message({
                        type: "error",
                        message: res.msg || "保存失败!"
                    });
                }
            }).catch(err => {
                console.log(err)
                done();
                this.btnLoading = false;
            })
        },
        show(option) {
            this.form.fileList = [];
            if (option.id) {
                setTimeout(() => {
                    getDetail(option.id).then(res =>{
                        if (res.data.success) {
                            this.form = res.data.data;
                            this.form.imgList.forEach(item =>{
                                if (!this.form.fileList) {
                                    this.form.fileList = [];
                                }
                                this.form.fileList.push(item.url);
                            })

                            this.findObject(this.option.column, 'createUserName').display=true;
                            this.findObject(this.option.column, 'createTime').display=true;
                            this.findObject(this.option.column, 'materialNo').display=true;
                            this.findObject(this.option.column, 'place').display=false;
                            this.findObject(this.option.column, 'materialNo').disabled=true;
                            this.findObject(this.option.column, 'isAssign').display=true;
                            this.findObject(this.option.column, 'assignName').display=true;
                            this.findObject(this.option.column, 'assignTime').display=true;
                            this.findObject(this.option.column, 'chartId').disabled=true;
                            setTimeout(() => {
                                this.form.packLabel = res.data.data.packLabel;
                                this.form.packLabel2 = res.data.data.packLabel2;
                                this.form.packLabel3 = res.data.data.packLabel3;
                            },500);
                        }
                    })
                }, 500);
            } else {
                this.form={}
                this.findObject(this.option.column, 'createUserName').display=false;
                this.findObject(this.option.column, 'createTime').display=false;
                this.findObject(this.option.column, 'materialNo').display=false;
                this.findObject(this.option.column, 'place').display=true;
                this.findObject(this.option.column, 'isAssign').display=false;
                this.findObject(this.option.column, 'assignName').display=false;
                this.findObject(this.option.column, 'assignTime').display=false;
                this.findObject(this.option.column, 'chartId').disabled=false;
            }
            this.title = option.title;
            this.type = option.type;
            this.option.detail = this.type === "view";
            this.editable = this.type !== "view";
            this.$refs.modal_1.show();
        },
      rowSave(row, done, loading) {
        add(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
            this.form = res.data.data;
          });
        }
        done();
      },
      searchReset() {
        this.query = {};
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
      currentChange(currentPage){
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize){
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
        this.loading = true;
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
        });
      },
        opened() {
            this.form.fileList = [];
            console.log("opened")
        },
        closed() {
            this.form.fileList = [];
            this.$emit("success");
        },
        uploadBefore (file, done, loading, column) {
            console.log(file, column)
            // var newFile = new File([file], '1234', { type: file.type });
            done(file)
            // this.$message.success('上传前的方法')
        },
        uploadAfter (res, done, loading, column) {
            console.log(res, column)
            if (!this.form.imgList) {
                this.form.imgList = [];
            }
            this.form.imgList.push(res);
            done()
            this.$message.success('上传成功！')
        },
        uploadDelete (file, column) {
            console.log(file, column)
            return new Promise((resolve, reject) => {
                if (this.form.imgList) {
                    this.form.imgList.forEach(item => {
                        if (item.url === file.url) {
                            console.log("删除项", item.url, file.url);
                            console.log(this.form.imgList.splice(item,1));
                        }
                        console.log(this.form.imgList);
                    })
                }
                resolve();
            });

        },
        uploadExceed (limit, files, fileList, column) {
            console.log(limit, files, fileList, column)
            this.$message.error('超出上传限制文件数量')
        },
        uploadError (error, column) {
            this.$message.error('上传失败！')
            console.log(error, column)
        }
    }
  };
</script>

<style>
</style>
